{extend name="base"/}
{block name="resources"}
{/block}
{block name="main"}
<div class="layui-form form-wrap">

	<div class="layui-form-item">
		<label class="layui-form-label">商品编码唯一性：</label>
		<div class="layui-input-block">
			<input type="checkbox" name="uniqueness_switch" value="1" lay-skin="switch" {if condition="$info.uniqueness_switch == 1" }checked {/if} lay-title="启用|关闭"/>
		</div>
		<div class="word-aux">开启后，将验证商品编码唯一性，不能重复</div>
	</div>

	<div class="form-row">
		<button class="layui-btn" lay-submit lay-filter="save">保存</button>
	</div>
</div>
{/block}

{block name="script"}
<script>
	layui.use(['form'], function() {
		var form = layui.form,
		repeat_flag = false; //防重复标识
		form.render();

		form.on('submit(save)', function(data) {
			if (repeat_flag) return;
			repeat_flag = true;

			$.ajax({
				url: ns.url("shop/goods/goodsno"),
				data: data.field,
				dataType: 'JSON',
				type: 'POST',
				success: function(res) {
					repeat_flag = false;
					layer.msg(res.message);
					if (res.code == 0) {
						location.reload();
					}
				}
			});
		});

	});
</script>
{/block}